﻿#region 命名空间

using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Caching;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using WinnerCMS.BLL;
using System.Linq;
using WinnerCMS.Model.Attribute;

#endregion

namespace WinnerCMS.WebUI.Admin.ControlPanel
{
    [Access]
    public partial class CacheExplorer : WebFactory.PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var type = Request["Type"];
            var dtCache = new DataTable();

            dtCache.Columns.Add(new DataColumn("Key", typeof (string)));


            if (type == "Session")
            {
                for (var i = 0; i < Session.Count; i++)
                {
                    dtCache.Rows.Add(Session[i].ToString());
                }
            }
            else if (type == "GetDBCount")
            {
                foreach (var v in new ModelManage().GetDBCount().OrderByDescending(x => x.Value))
                {
                    dtCache.Rows.Add(string.Format("{0}：{1}", v.Key, v.Value));
                }
            }
            else
            {
                foreach (DictionaryEntry de in HttpRuntime.Cache)
                {
                    dtCache.Rows.Add(de.Key);
                }
            }
            var dv = new DataView(dtCache);

            this.DataList1.DataSource = dv;
            this.DataList1.DataBind();
        }
    }
}